home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
- Subject: Re: float != float and floats as return types
- Date: 01 Feb 1996 23:40:22 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb1164022@qcd.lanl.gov>
- References: <4ej9lb$mpc@fu-berlin.de> <4elnjj$er4@server2.rz.uni-leipzig.de>
- <4eqc7l$ugh@godzilla.zeta.org.au> <4eqtu3$ddo@der.twinsun.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: eggert@twinsun.com's message of 1 Feb 1996 09:40:19 -0800
-
- In article <4eqtu3$ddo@der.twinsun.com> eggert@twinsun.com (Paul
- Eggert) writes:
- <snip>
- bde@zeta.org.au (Bruce Evans) writes:
-
- > a = 1.0;
- > b = FLT_EPSILON / 4.0;
- > c = a + b;
- > assert(c == (float) (a + b));
-
- As far as I can tell the C Standard allows the assertion to either
- succeed or fail, depending on the implementation. The key phrase in
- the standard is ``The values of floating operands and of the results of
- floating expressions may be represented in greater precision and range
- than that required by the type''. So `c' might be represented in more
- bits than `(float) (a + b)' (or vice versa! though this is more
- controversial since it contradicts the Rationale, and it may be
- corrected by the committee soon), and the assertion might fail.
-
- I do not agree with this interpretation, as the footnote (technically,
- not part of the standard) clarifies: an assignment and cast both must
- truncate the result to the required precision. It can be subsequently
- widened to more precision: but that is a different matter.
-
- Now whether `a+b' must always give the same answer (for constant a and
- b) may be debatable: but certainly not outside comp.std.c (or c++) :-)
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-